fix(seo): trailing slash consistency for hreflang/canonical/sitemap#236
Merged
Conversation
…map URLs Semrush flagged 9 hreflang conflicts because Vercel serves both /en and /en/ as 200 (no redirect), so whichever form tags use conflicts with the alternate crawled URL. Fix: enable trailingSlash: true in Next.js config so Vercel redirects /en → /en/ (308). Update page.tsx and sitemap generator to produce trailing-slash URLs consistently across: - <link rel="canonical"> - <link rel="alternate" hreflang> - sitemap.xml <loc> and <xhtml:link> Build tested locally — static export now generates directory-based index.html files (en/index.html instead of en.html).
Collaborator
Author
|
Merge gate (auto-classified): gate=smoke-passed — auto-classified by the gate-log enforcer (9min after merge, no Posted by |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
trailingSlash: truein Next.js config — Vercel will 308-redirect/en→/en/page.tsxto produce trailing-slash canonical and hreflang URLs for all pages<loc>and<xhtml:link>URLsRoot cause
Vercel serves both
/enand/en/as HTTP 200 with identical content (no redirect). Semrush discovers URLs from the sitemap (no trailing slash) and from internal links (with trailing slash), treats them as distinct, and flags the mismatch between the crawled URL and canonical/hreflang tags.What changes
next.config.mjs: addedtrailingSlash: truepage.tsx: all canonical/hreflang/OG URLs now end with/generate-sitemap.mjs: all<loc>and hreflanghrefURLs now end with/en/index.htmlinstead ofen.html(directory-based)Test plan
/en→/en/after deploy